<template>
    <div id="member">
        <el-col :span="24" class="action-bar">
                <el-button type="primary" size="medium" @click="signatureVisible=true">添加</el-button>
            </el-col>
        

        <!-- 列表 -->
        <el-table
            :data="tableData"
            style="width: 100%">
            <el-table-column
                prop="name"
                label="名称"
                width="200"
                >
            </el-table-column>
            <el-table-column
                prop="created_at"
                label="创建时间"
                width="200"
                >
            </el-table-column>
            <!-- <el-table-column
                prop="status_name"
                label="排序"
                width="100"
                >
            </el-table-column> -->
            
            <el-table-column label="操作" width='143'>
                <template slot-scope="scope">
                    <el-button type='text' @click="deleteCircle(scope.row.id)" >删除</el-button>
                </template>
            </el-table-column>
            
        </el-table>

		<el-dialog title="圈子类型" :visible.sync="signatureVisible" @close="initData">
            <el-form>
                <el-form-item label="圈子类型">
                    <el-input placeholder="圈子类型" v-model="name"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submit" >提交</el-button>
			</div>
		</el-dialog>
    </div>
</template>
<script>
export default {
    name:'member',
    data() {
        return {
            name:'',
            signatureVisible:false,//编辑弹窗
            circleTypeId:'',//选中的用户id
            tableData: [{}],
            page:1,
            totalPage:0    
        }
    },
    methods: {      
        async getCircleClassifyList(){
            //获取圈子类型
            let params={
                page:this.page,
                limit:16,
            }
            let res=await this.$api.getCircleClassifyList(
                params);
            if(res.data.level=='success'){
                this.tableData=res.data.data;
                // this.totalPage=res.data.page_info.total;
            }
        },
        pageChange(e){
			//翻页
			this.page=e;
			this.getCircleClassifyList();
        },
        async deleteCircle(id){
            //删除圈子类型
             let judge=null
            try {
              judge=  await this.$confirm('删除该圈子类型?请不要随意删除', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
                })
            } catch (error) {
                judge='cancel'
            }
            if(judge=='confirm'){
                let res=await this.$api.delCircleClassify({id:id});
                
                if(res.data.level=='success'){
                        this.$message({
                            type:'success',
                            message:res.data.message
                        })
                        this.signatureVisible=false
                        this.getCircleClassifyList()
                    }else{
                        this.$message({
                            type:'error',
                            message:res.data.message
                        })
                    }
              
            }
            console.log(judge)
        },
        async submit(){
            //新增
            let params={
                name:this.name
            }
            let res=await this.$api.adminAddCircleClassify(params);
            if(res.data.level=='success'){
                this.$message({
                    type:'success',
                    message:res.data.message
                })
                this.signatureVisible=false
                this.getCircleClassifyList()
            }else{
                this.$message({
                    type:'error',
                    message:res.data.message
                })
                
            }
            
        },
        initData(){

        }

    },
    mounted() {
        this.getCircleClassifyList()
    },
}
</script>
<style lang="scss" scoped>
.screen{
          margin-top: -10px !important;
      }
    .action-bar{
			background-color: #f2f2f2;
			height: 60px;
			margin: 10px 0px;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			padding-left: 20px;
			.action-bar-input{
				width: 250px;
				margin-right: 14px;
      }
      .task-form-text{
				color: #666666;
			}
		}
		.el-table-style{
			width: 100%;
			border: 1px solid #f2f2f2;
		}
		.footer-bar{
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: #f2f2f2;
			padding: 8px;
			margin: 10px 0px;
			box-sizing: border-box;
		}
		.dialog-footer{
			text-align: center;
		}
		.executorList{
			display: flex;
			flex-wrap: wrap;
			div{
				margin:10px;
				border:1px solid #eee;
				border-radius: 5px;
				padding:5px 10px;
			}
		}
</style>